#include "GameEngine.h"
#include "EngineWindow.h"
#include "EngineRender.h"

GameEngine::GameEngine(const EngineSetup& setup)
	: m_setup(setup) {

	m_window = CreateEngineWindow(setup.Window);
    RenderSetup renderSetup;
    renderSetup.Window = m_window;
	m_renderDevice = CreateEngineRenderDevice(renderSetup, m_setup.RenderType);
    m_renderContext = m_renderDevice->GetRenderContext();
}

GameEngine::~GameEngine() {

}

void GameEngine::Release() {
    delete this;
}

void GameEngine::Run() const {
    m_renderContext->Clear();
    m_renderDevice->Present();
    while (m_window->ProcessMessage() != WND_QUIT)
    {
        m_renderContext->Clear();
        m_renderDevice->Present();
    }
}

inline IWindow* GameEngine::GetWindow() const {
    return m_window.get();
}

IGameEngine* CreateGameEngine(const EngineSetup& setup) {
	return new GameEngine(setup);
}